package com.xiaomei.manager.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xiaomei.manager.dao.AdvertisementMapper;
import com.xiaomei.manager.model.Advertisement;
import com.xiaomei.manager.service.IAdvertisementService;
import com.xiaomei.manager.web.dto.req.AdvertQueryDto;
import com.xiaomei.manager.web.page.Page;

@Service
public class AdvertisementServiceImpl implements IAdvertisementService {
	
	@Autowired
	private AdvertisementMapper advertisementMapper;
	/**
	 * 上传广告
	 */
	@Override
	public boolean createAdvert(Advertisement advertisement) {
		// TODO 自动生成的方法存根
		
		if(advertisementMapper.insertSelective(advertisement)>0){
			return true;
		}else{
			return false;		
		}	
	}
	@Override
	public Integer selectMaxID() {
		// TODO 自动生成的方法存根
		return advertisementMapper.selectMaxId();
	}
	@Override
	public List<Advertisement> getAdvertForList(AdvertQueryDto paramDto,
			Page<Advertisement> page) {
		// TODO Auto-generated method stub
		page.setParamDto(paramDto);
		return advertisementMapper.selectByParamMap(page);
	}
	@Override
	public Advertisement findOne(Integer id) {
		// TODO Auto-generated method stub
		return advertisementMapper.selectByPrimaryKey(id);
	}
	@Override
	public Advertisement selectExperienceById(Integer id) {
		// TODO Auto-generated method stub
		return advertisementMapper.selectByPrimaryKey(id);
	}
	@Override
	public boolean updateExperience(Advertisement advertisement) {
		// TODO Auto-generated method stub
		if(advertisementMapper.updateByPrimaryKeySelective(advertisement)>0){
			return true;
		}else{
			return false;
		}
	}
		@Override
		public boolean deleteExperience(Integer id) {
			if(advertisementMapper.deleteByPrimaryKey(id) > 0){
				return true;
			}
			return false;
		}
	
	
}
